package com.example.demo_scan;

import android.content.Intent;

import androidx.annotation.NonNull;

import java.nio.channels.NetworkChannel;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;

public class JumpChannel implements MethodChannel.MethodCallHandler {

    private String  batteryChannelName = "demo_scan";
    private MethodChannel channel;
    private FlutterActivity mActivity;

    public JumpChannel(BinaryMessenger flutterEngine, FlutterActivity activity) {
        channel = new MethodChannel(flutterEngine, batteryChannelName);
        channel.setMethodCallHandler(this);
        mActivity = activity;
    }

    @Override
    public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
        if (call.method.equals("scan")) {
            Intent intent = new Intent(mActivity, QRCodeActivity.class);
            mActivity.startActivity(intent);
            result.success("跳转");
        } else if (call.method.equals("dismiss")) {
            //            mActivity.finish();
            result.success("dismiss");
        } else if (call.method.equals("getPlatformVersion")) {
            result.success("Android " + android.os.Build.VERSION.RELEASE);
        } else {
            result.notImplemented();
        }
    }
}
